/*
 * Name: Joon Ho Cho
 * Date: 10/24/2008
 * Course: 15-437
 */
package scheduler.formbean;

import java.util.ArrayList;
import java.util.List;

public class RegisterForm {
	//private String email;
	private String name;
	private String password;
	private String confirmPassword;
	/*private String gender;
	private String age;
	private String year;
	private String major1;
	private String major2;
	private String minor;
	*/
//	public String getEmail()  { return email; }
	public String getName()  { return name; }
	public String getPassword()  { return password; }
	public String getConfirmPassword()  { return confirmPassword; }
	/*public String getGender()  { return gender; }
	public String getAge()  { return age; }
	public String getYear()  { return year; }
	public String getMajor1()  { return major1; }
	public String getMajor2()  { return major2; }
	public String getMinor()  { return minor; }
	*/
	//public void setEmail(String s)  { email = s.trim(); }
	public void setName(String s)  { name = s.trim(); }
	public void setPassword(String s)  { password = s.trim(); }
	public void setConfirmPassword(String s)  { confirmPassword = s.trim(); }
/*	public void setGender(String s)  { gender = s.trim(); }
	public void setAge(String s)  { age = s.trim(); }
	public void setYear(String s)  { year = s.trim(); }
	public void setMajor1(String s)  { major1 = s.trim(); }
	public void setMajor2(String s)  { major2 = s.trim(); }
	public void setMinor(String s)  { minor = s.trim(); }
*/	
	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();
		
	/*	if (email == null || email.length() == 0) {
			errors.add("Email address is required");
		}
*/
		if (name == null || name.length() == 0) {
			errors.add("Name is required");
		}

		if (password == null || password.length() == 0) {
			errors.add("Password is required");
		}

		if (confirmPassword == null || confirmPassword.length() == 0) {
			errors.add("Confirm password is required");
		}
		
		if (errors.size() > 0) return errors;
		
		if (!password.equals(confirmPassword)) {
			errors.add("Password and Confirm password do not match");
		}
		
		return errors;
	}
	
	public boolean isPresent() {
	//	if (email != null) return true;
		if (name != null) return true;
		if (password != null) return true;
		if (confirmPassword != null) return true;
		return false;
	}
}
